# coding:utf-8
# 导包
from selenium import webdriver
import time
# 创建浏览器对象
driver = webdriver.Chrome()
url = 'http://www.baidu.com'
driver.get(url)

print("当前url:" , driver.current_url)
print('当前标题:',driver.title)
# 获取截图，存在内存中
data = driver.get_screenshot_as_png()
# 保存截图
f = open('baidu.png', 'wb')
f.write(data)
f.close()
# 直接将截图保存文件
driver.get_screenshot_as_file('baidu2.jpg')
# 打印源码
page = driver.page_source.encode()
with open('baidu.html','wb')as f:
    f.write(page)
print ('******')
# 关闭浏览器对象
time.sleep(5)
driver.close()

